package com.rs.controller;

import java.awt.EventQueue;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import com.rs.model.ZhClasses;
import com.rs.service.ZhClassesService;
import com.rs.util.DateFormatUtil;
import com.rs.util.SpringContextUtils;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class ClassListUpdate extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField txtS;
	private JTextField txtSw;
	private JTextField txtS_2;
	private JTextField txtS_3;
	private JTextField txtS_4;
	private JTextField txtS_5;
	private JTextField textField_9;
	
	private ZhClassesService zhClassesService = SpringContextUtils.getBean(ZhClassesService.class);
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ClassListUpdate frame = new ClassListUpdate(null,null);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public ClassListUpdate(final ZhClasses zhClasses , final JDesktopPane desktopPane_1) {
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				ClassList zhLeanprogressList = new ClassList(desktopPane_1,zhClasses.getClShuid());
				zhLeanprogressList.setVisible(true);
				desktopPane_1.add(zhLeanprogressList);
			}
		});
		setIconImage(Toolkit.getDefaultToolkit().getImage(ClassListUpdate.class.getResource("/images/logo1.png")));
		setTitle("修改");
		setBounds(100, 100, 601, 426);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("编号：");
		lblNewLabel.setBounds(56, 42, 54, 15);
		contentPane.add(lblNewLabel);
		
		textField = new JTextField();
		textField.setText(String.valueOf(zhClasses.getClId()));
		textField.setEditable(false);
		textField.setBounds(132, 39, 90, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel lblNewLabel_1 = new JLabel("教师姓名：");
		lblNewLabel_1.setBounds(56, 100, 66, 15);
		contentPane.add(lblNewLabel_1);
		
		txtS = new JTextField();
		txtS.setText(zhClasses.getClUName());
		txtS.setEditable(false);
		txtS.setBounds(132, 97, 90, 21);
		contentPane.add(txtS);
		txtS.setColumns(10);
		
		JLabel lblNewLabel_4 = new JLabel("开班时间：");
		lblNewLabel_4.setBounds(325, 42, 66, 15);
		contentPane.add(lblNewLabel_4);
		
		txtSw = new JTextField();
		txtSw.setText(zhClasses.getClTimeString());
		txtSw.setEditable(false);
		txtSw.setBounds(413, 39, 90, 21);
		contentPane.add(txtSw);
		txtSw.setColumns(10);
		
		JLabel lblNewLabel_5 = new JLabel("结业时间：");
		lblNewLabel_5.setBounds(325, 100, 66, 15);
		contentPane.add(lblNewLabel_5);
		
		txtS_2 = new JTextField();
		txtS_2.setText(zhClasses.getClEndtimeString());
		txtS_2.setEditable(false);
		txtS_2.setBounds(413, 97, 90, 21);
		contentPane.add(txtS_2);
		txtS_2.setColumns(10);
		
		JLabel lblNewLabel_6 = new JLabel("班级人数：");
		lblNewLabel_6.setBounds(56, 168, 66, 15);
		contentPane.add(lblNewLabel_6);
		
		txtS_3 = new JTextField();
		txtS_3.setText(String.valueOf(zhClasses.getClStudentnum()));
		txtS_3.setEditable(false);
		txtS_3.setBounds(132, 165, 90, 21);
		contentPane.add(txtS_3);
		txtS_3.setColumns(10);
		
		JLabel lblNewLabel_8 = new JLabel("审批人：");
		lblNewLabel_8.setBounds(325, 168, 54, 15);
		contentPane.add(lblNewLabel_8);
		
		txtS_4 = new JTextField();
		txtS_4.setText(zhClasses.getClShuname());
		txtS_4.setEditable(false);
		txtS_4.setBounds(413, 165, 90, 21);
		contentPane.add(txtS_4);
		txtS_4.setColumns(10);
		
		JLabel lblNewLabel_9 = new JLabel("审核状态：");
		lblNewLabel_9.setBounds(56, 236, 66, 15);
		contentPane.add(lblNewLabel_9);
		
		txtS_5 = new JTextField();
		txtS_5.setText(String.valueOf(zhClasses.getClExamine()));
		txtS_5.setBounds(132, 233, 90, 21);
		contentPane.add(txtS_5);
		txtS_5.setColumns(10);
		
		textField_9 = new JTextField();
		textField_9.setEditable(false);
		textField_9.setText("审核状态（0.待审核 1.审核通过 2.审核未通过）");
		textField_9.setBounds(244, 233, 282, 21);
		contentPane.add(textField_9);
		textField_9.setColumns(10);
		
		JButton btnNewButton = new JButton("修改");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int a =zhClasses.getClShuid();
				ZhClasses zhClasses = new ZhClasses();
				zhClasses.setClId(Integer.parseInt(textField.getText()));
				zhClasses.setClExamine(Integer.parseInt(txtS_5.getText()));
				zhClasses.setClShuid(a);
				zhClassesService.updateGraduationAudit(zhClasses);
				showMessageDialog("修改成功");
			}
		});
		btnNewButton.setBounds(413, 331, 93, 23);
		contentPane.add(btnNewButton);
	}
	//提示弹窗
			public void showMessageDialog(String massage){
				JOptionPane.showMessageDialog(this,massage);
			}
}
